package com.zmn.mcc.cas.server;

/**
 * 验证码
 *
 * @author quanjic
 * @version v1.0
 * @since 2020/6/16 14:22
 **/
public interface CaptchaService {

    /**
     * 生成GIT图片校验码；有效时间一小时
     *
     * @return
     */
    GifCaptcha generateGif();

    /**
     * 校验
     *
     * @param key  唯一标识
     * @param code 用户输入验证码
     * @return
     */
    boolean check(String key, String code);

    class GifCaptcha {

        private String code;
        private String key;
        private byte[] bytes;

        public GifCaptcha(String key, String code, byte[] bytes) {
            this.key = key;
            this.code = code;
            this.bytes = bytes;
        }

        public String getCode() {
            return code;
        }

        public byte[] getBytes() {
            return bytes;
        }

        public String getKey() {
            return key;
        }
    }

}
